const domainName = getApp().globalData.domainName
const parameter = {
  dataType: 'json',
  enableCache: true,
  enableHttp2: true,
  enableQuic: true,
  header : {'content-type':'application/x-www-form-urlencoded'},
  method: 'POST',
  responseType: 'text',
  timeout: 0,
}




  // 加载训练日期列表
const load_exam_date_list=(that,jg_id)=>{
    wx.showLoading()
    wx.request({
      url: domainName + '/load_exam_date_list',
      data: {
        jg_id:jg_id,
      },
      ...parameter,
      success: res => {
        wx.hideLoading()
        // console.log('加载训练日期列表',res.data)
        
        let exam_date_list = res.data.exam_date_list
        console.log('exam_date_list',exam_date_list)
        // let exam_date_list = []
        if(exam_date_list.length>0){
          let exam_date = exam_date_list[exam_date_list.length-1]
          let exam_date_list_list = exam_date.split('-')
          that.setData({
            exam_date_list:exam_date_list,
            scroll_test_date:'id' + (exam_date_list.length-1),
            exam_date:exam_date,
            exam_date_str:exam_date_list_list[0] + '年' + exam_date_list_list[1] + '月' + exam_date_list_list[2] +'日'
          })
          that.setData({
            jg_StuLabel_list:res.data.jg_StuLabel_list
          })

          // 加载侧边训练项目
          load_exam_cert_list(that,jg_id, exam_date)
        }
        
      },
    })
  }



const load_exam_cert_list=(that,jg_id, exam_date)=>{
  console.log('exam_date',exam_date)
    wx.request({
      url: domainName + '/load_examCertList_of_jg',
      data: {
        jg_id:jg_id,
        exam_date:exam_date,
      },
      ...parameter,
      success: res => {
        that.setData({
          cert_list:res.data.cert_list
        })
      },
    })
  }

  module.exports={
    load_exam_date_list,
    load_exam_cert_list,
  }